
package com.sinpo.xnfc.card;

import com.sinpo.xnfc.card.pboc.PbocCard;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.tech.IsoDep;
import android.nfc.tech.NfcF;
import android.nfc.tech.NfcV;
import android.os.Build;
import android.os.Parcelable;
import android.widget.Toast;

@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)
@SuppressLint("NewApi")
public final class CardManager {
        private static final String SP = "<br/><img src=\"spliter\"/><br/>";

        public static String[][] TECHLISTS;
        public static IntentFilter[] FILTERS;

        static {
                try {
                        TECHLISTS = new String[][] { { IsoDep.class.getName() },
                                        { NfcV.class.getName() }, { NfcF.class.getName() }, };

                        FILTERS = new IntentFilter[] { new IntentFilter(
                                        NfcAdapter.ACTION_TECH_DISCOVERED, "*/*") };
                } catch (Exception e) { ;
                
                					}
        }

        public static String buildResult(String n, String i, String d, String x) {
                if (n == null)
                        return null;

                final StringBuilder s = new StringBuilder();

                s.append("<br/><b>").append(n).append("</b>");

                if (i != null)
                        s.append(SP).append(i);

                if (d != null)
                        s.append(SP).append(d);

                if (x != null)
                        s.append(SP).append(x);

                return s.append("<br/><br/>").toString();
        }

        public static String load(Parcelable parcelable, Resources res) {
                final Tag tag = (Tag) parcelable;

                final IsoDep isodep = IsoDep.get(tag);
                if (isodep != null) {
                        return PbocCard.load(isodep, res);
                }

             /*   final NfcV nfcv = NfcV.get(tag);
                if (nfcv != null) {
                        return VicinityCard.load(nfcv, res);
                }

                final NfcF nfcf = NfcF.get(tag);
                if (nfcf != null) {
                        return OctopusCard.load(nfcf, res);
                }
					*/
                return null;
        }
}
